package com.zzx.boot.message;

import com.zzx.boot.emus.ChatTypes;
import com.zzx.boot.websocket.session.WebSocketSession;
import io.netty.channel.Channel;
import io.netty.channel.ChannelHandlerContext;
import lombok.Data;

@Data
public class ChitchatMessage extends Message {
    private Long toId;
    private Long fromId;
    private String content;
    private Long time;
    private Boolean status;
    //
    @Override
    public ChatTypes getType() {
        return ChatTypes.CHITCHAT;
    }

    @Override
    public void send(ChannelHandlerContext ctx) {
        // 1. 获取toId channel
        Channel channel = WebSocketSession.getSession(String.valueOf(this.toId));
        channel.writeAndFlush(this.toText(this));
    }
}
